package a.f.h.c;

import a.c.*;
import a.c.e;
import a.c.m;
import a.f.h.b.f;
import a.f.h.b.j;

import java.util.Comparator;
import java.util.Iterator;

public class l
{
  public static final short a = 0;
  public static final short b = 1;
  private static final int c = 2147483647;
  private int d;
  private f e;
  private q f;
  private a.c.n g;
  private a.c.n h;
  private a.c.x i;
  private a.c.x j;
  private a.c.x k;
  private a l;
  private int m;
  private z n;
  private d[] o;
  private boolean p = false;
  public static int q;
  
  public l(int paramInt, f paramf)
  {
    this.d = paramInt;
    this.e = paramf;
    a(paramInt, paramf);
    a();
  }
  
  public void a()
  {
    b(this.d, this.e);
    d(this.d, this.e);
  }
  
  public void c()
  {
    b(this.d, this.e);
  }
  
  public void d()
  {
    this.e.a().a(this.k);
    this.f = null;
    this.l = null;
    this.n = null;
    this.o = null;
  }
  
  public Iterator e()
  {
    return this.n.iterator();
  }
  
  public y f()
  {
    return this.n.h();
  }
  
  public int g()
  {
    return this.m;
  }
  
  public d a(e parame)
  {
    return (d)this.k.get(parame);
  }
  
  public d a(a.c.d paramd)
  {
    return a(paramd.e());
  }
  
  public m h()
  {
    return this.f.w();
  }
  
  public double c(a.c.d paramd)
  {
    if (!d.o) {
      if (this.p) {
        return a(paramd.e(), paramd.f());
      }
    }
    return this.g.getDouble(paramd);
  }
  
  public double a(e parame1, e parame2)
  {
    if ((d.o) || (this.p)) {
      return this.l.a(b(parame1).c(), b(parame2).c());
    }
    a.c.d locald = parame1.a(parame2);
    if (locald == null) {
      return 2147483647.0D;
    }
    return this.g.getDouble(locald);
  }
  
  public int a(d paramd1, d paramd2)
  {
    boolean bool = d.o;
    if (!bool)
    {
      if (paramd1.d() == this.d) {
        if (bool) {
          break label48;
        }
      }
    }
    else {
      if (paramd2.d() == this.d) {
        break label44;
      }
    }
    throw new RuntimeException("Invalid call to get min-dist !");
    label44:
    label48:
    if (!bool) {
      if (!this.p) {
        throw new RuntimeException("getMinDist not permitted in nonmatrix mode");
      }
    }
    return this.l.a(paramd1.c(), paramd2.c());
  }
  
  public d b(e parame)
  {
    return (d)this.i.get(parame);
  }
  
  public a.c.d a(d paramd1, d paramd2, int paramInt)
  {
    boolean bool = d.o;
    if (!bool)
    {
      if (paramd1.d() == this.d) {
        if (bool) {
          break label48;
        }
      }
    }
    else {
      if (paramd2.d() == this.d) {
        break label47;
      }
    }
    throw new RuntimeException("Invalid call to set min-dist !");
    label47:
    label48:
    e locale1 = paramd1.b();
    e locale2 = paramd2.b();
    paramInt += paramd1.o() + paramd2.n();
    a.c.d locald;
    if (!bool) {
      if (!this.p)
      {
        locald = locale1.a(locale2);
        if ((bool) || (locald == null))
        {
          if (bool) {
            break label183;
          }
          locald = this.f.a(locale1, locale2);
          this.g.a(locald, paramInt);
          a(locald, 0);
          if (d.n == 0) {}
        }
        else if ((bool) || (this.g.getDouble(locald) < paramInt))
        {
          this.g.a(locald, paramInt);
        }
        label183:
        return locald;
      }
    }
    if (!bool) {
      if (this.l.a(paramd1.c(), paramd2.c()) == 2147483647)
      {
        this.l.a(paramd1.c(), paramd2.c(), paramInt);
        locald = this.f.a(locale1, locale2);
        a(locald, 0);
        return locald;
      }
    }
    if ((bool) || (this.l.a(paramd1.c(), paramd2.c()) < paramInt)) {
      this.l.a(paramd1.c(), paramd2.c(), paramInt);
    }
    return null;
  }
  
  public k a(d paramd)
  {
    e locale = paramd.b();
    return (k)this.j.get(locale);
  }
  
  public void a(a.c.d paramd, int paramInt)
  {
    this.h.a(paramd, paramInt);
  }
  
  public int d(a.c.d paramd)
  {
    Object localObject = this.h.get(paramd);
    if (localObject == null) {
      return 0;
    }
    return this.h.getInt(paramd);
  }
  
  public boolean b(d paramd1, d paramd2)
  {
    boolean bool = d.o;
    if (!bool) {
      if (!this.p) {
        throw new RuntimeException("areSeparated in non-matrix mode");
      }
    }
    if (!bool) {}
    return this.l.a(paramd1.c(), paramd2.c()) != 2147483647;
  }
  
  public void c(d paramd1, d paramd2)
  {
    boolean bool = d.o;
    int i3 = d.n;
    if (!this.p) {
      throw new RuntimeException("separate in non-matrix mode");
    }
    d locald1 = paramd1;
    m localm1 = paramd1.b().m();
    m localm2 = paramd2.b().n();
    d locald2 = paramd2;
    int i1 = this.l.a(locald1.c(), locald2.c());
    label203:
    label210:
    do
    {
      if (i1 == 2147483647)
      {
        a.c.d locald = this.f.a(locald1.b(), locald2.b());
        this.l.a(locald1.c(), locald2.c(), 1);
        a(locald, 0);
        if (bool) {
          break label210;
        }
        if (i3 != 0) {
          break label203;
        }
        if (bool) {
          break label210;
        }
        if (i3 == 0) {
          break label203;
        }
      }
      do
      {
        int i2 = this.l.a(locald1.c(), paramd1.c()) + this.l.a(paramd2.c(), locald2.c()) + 1;
        if (!bool) {
          if (i2 > i1) {
            this.l.a(locald1.c(), locald2.c(), i2);
          }
        }
        if (bool) {
          break label258;
        }
        if (localm2.e())
        {
          locald2 = b(localm2.a().f());
          localm2.f();
          if (i3 == 0) {
            break;
          }
        }
      } while (bool);
      if (!bool)
      {
        if (localm1.e())
        {
          locald1 = b(localm1.a().e());
          localm1.f();
        }
      }
      else {
        if (i3 == 0) {
          break;
        }
      }
    } while (bool);
    label258:
  }
  
  private void a(int paramInt, f paramf)
  {
    boolean bool = d.o;
    int i1 = d.n;
    q localq = paramf.a();
    a.f.h.b.k localk1;
    a.f.h.b.k localk2;
    short s;
    if (!bool) {
      switch (paramInt)
      {
      case 0: 
        localk1 = a.f.h.b.k.c;
        localk2 = a.f.h.b.k.a;
        s = 0;
        if (bool) {
          break label163;
        }
        if (i1 == 0) {
          break;
        }
      case 1: 
        localk1 = a.f.h.b.k.b;
        localk2 = a.f.h.b.k.d;
        s = 1;
        if (bool) {
          break label163;
        }
        if (i1 == 0) {
          break;
        }
      default: 
        a.i.n.a("Constraint Graph Constructor: Unknown type:" + paramInt);
      }
    } else {
      return;
    }
    this.f = new q();
    this.i = this.f.B();
    this.k = localq.B();
    this.n = new z();
    this.m = 0;
    label163:
    Object localObject1 = localq.v();
    Object localObject2;
    label412:
    label414:
    do
    {
      do
      {
        if (!((w)localObject1).e()) {
          break label417;
        }
        localObject2 = ((w)localObject1).d();
        if (bool) {
          break label434;
        }
        a.c.d locald = a((e)localObject2, localk2, paramf);
        if (i1 != 0) {
          break label433;
        }
        if (locald == null)
        {
          e locale = this.f.i();
          d locald1 = new d(locale, this.m, s);
          this.n.add(locald1);
          this.m += 1;
          this.i.a(locale, locald1);
          this.k.a(localObject2, locald1);
          locald1.a((e)localObject2);
          locald = a((e)localObject2, localk1, paramf);
          do
          {
            if (locald == null) {
              break;
            }
            localObject2 = locald.f();
            locald1.a((e)localObject2);
            this.k.a(localObject2, locald1);
            locald1.c(Math.max(paramf.m(locald), locald1.n()));
            locald1.d(Math.max(paramf.n(locald), locald1.o()));
            locald = a((e)localObject2, localk1, paramf);
            if (bool) {
              break label414;
            }
            if (i1 != 0) {
              break label412;
            }
          } while (i1 == 0);
        }
      } while (bool);
      ((w)localObject1).f();
    } while (i1 == 0);
    label417:
    if (!bool) {
      this.o = new d[this.m];
    }
    label433:
    label434:
    localObject1 = this.n.iterator();
    if (((Iterator)localObject1).hasNext()) {}
    do
    {
      localObject2 = (d)((Iterator)localObject1).next();
      this.o[localObject2.c()] = localObject2;
      if ((!bool) && (i1 != 0)) {
        return;
      }
      if (i1 == 0) {
        break;
      }
      this.g = this.f.C();
    } while (bool);
    this.h = this.f.C();
  }
  
  private void b(int paramInt, f paramf)
  {
    boolean bool = d.o;
    int i2 = d.n;
    this.p = false;
    q localq = paramf.a();
    Object localObject1 = this.f.w();
    do
    {
      do
      {
        if (!((m)localObject1).e()) {
          break;
        }
        this.f.a(((m)localObject1).a());
        ((m)localObject1).f();
        if ((!bool) && (i2 != 0)) {
          break label108;
        }
      } while (i2 == 0);
    } while (bool);
    label108:
    a.f.h.b.k localk;
    switch (paramInt)
    {
    case 0: 
      localObject1 = a.f.h.b.k.b;
      localk = a.f.h.b.k.d;
      break;
    case 1: 
      localObject1 = a.f.h.b.k.c;
      localk = a.f.h.b.k.a;
      break;
    default: 
      a.i.n.a(this, 1, "Constraint Graph Constructor: Unknown type:" + paramInt);
      return;
    }
    Object localObject2 = localq.w();
    Object localObject3;
    d locald1;
    d locald2;
    do
    {
      if (!((m)localObject2).e()) {
        break;
      }
      localObject3 = ((m)localObject2).a();
      if (i2 != 0) {
        break label370;
      }
      if (paramf.k((a.c.d)localObject3))
      {
        locald1 = null;
        locald2 = null;
        if (paramf.i((a.c.d)localObject3).c((a.f.h.b.k)localObject1))
        {
          locald1 = a(((a.c.d)localObject3).e());
          locald2 = a(((a.c.d)localObject3).f());
        }
        if (paramf.i((a.c.d)localObject3).c(localk))
        {
          locald1 = a(((a.c.d)localObject3).f());
          locald2 = a(((a.c.d)localObject3).e());
        }
        if ((bool) || ((locald1 != null) && (locald2 != null)))
        {
          a.c.d locald = a(locald1, locald2, paramf.j((a.c.d)localObject3));
          int i1 = (int)paramf.l((a.c.d)localObject3);
          if (bool) {
            continue;
          }
          if (d(locald) < i1) {
            a(locald, i1);
          }
        }
      }
      ((m)localObject2).f();
    } while (i2 == 0);
    if (!bool) {
      localObject2 = paramf.l();
    }
    label370:
    do
    {
      if (!((y)localObject2).e()) {
        break;
      }
      localObject3 = (j)((y)localObject2).j();
      if (((j)localObject3).d() != 2)
      {
        locald1 = null;
        locald2 = null;
        if (((j)localObject3).e().c((a.f.h.b.k)localObject1))
        {
          locald1 = a(((j)localObject3).a());
          locald2 = a(((j)localObject3).b());
        }
        if (((j)localObject3).e().c(localk))
        {
          locald1 = a(((j)localObject3).b());
          locald2 = a(((j)localObject3).a());
        }
        if ((bool) || ((locald1 != null) && (locald2 != null))) {
          a(locald1, locald2, ((j)localObject3).c());
        }
      }
      ((y)localObject2).f();
    } while (i2 == 0);
  }
  
  public void i()
  {
    boolean bool = d.o;
    int i8 = d.n;
    a.i.n.a(this, 3, "-----> All Pair Longest Path:");
    this.p = true;
    this.l = new a(this.m);
    int i1 = 0;
    label106:
    do
    {
      if (i1 >= this.m) {
        break;
      }
      int i2 = 0;
      do
      {
        do
        {
          if (i2 >= this.m) {
            break label106;
          }
          if (i8 != 0) {
            break;
          }
          if (i1 != i2)
          {
            this.l.a(i1, i2, 2147483647);
            if (bool) {
              continue;
            }
            if (i8 == 0) {}
          }
          else
          {
            this.l.a(i1, i2, 0);
          }
          i2++;
        } while (i8 == 0);
        i1++;
      } while (bool);
    } while (i8 == 0);
    Object localObject1 = this.f.w();
    do
    {
      if (!((m)localObject1).e()) {
        break;
      }
      localObject2 = ((m)localObject1).a();
      if (!bool)
      {
        if (i8 != 0) {
          break label205;
        }
        this.l.a(b(((a.c.d)localObject2).e()).c(), b(((a.c.d)localObject2).f()).c(), (int)this.g.getDouble(localObject2));
        ((m)localObject1).f();
      }
    } while (i8 == 0);
    label205:
    localObject1 = a.a.x.a(this.f);
    Object localObject2 = ((bb)localObject1).l();
    label445:
    label470:
    do
    {
      if (!((w)localObject2).e()) {
        break;
      }
      e locale1 = ((w)localObject2).d();
      int i3 = b(locale1).c();
      m localm = locale1.n();
      do
      {
        do
        {
          if (!localm.e()) {
            break label470;
          }
          e locale2 = localm.a().f();
          int i4 = b(locale2).c();
          int i5 = this.l.a(i3, i4);
          if (i8 != 0) {
            break;
          }
          int i6 = 0;
          do
          {
            do
            {
              while (i8 != 0) {
                if (i6 >= this.m) {
                  break;
                }
              }
              if (this.l.a(i6, i3) < 2147483647)
              {
                int i7 = this.l.a(i6, i3) + i5;
                if (!bool)
                {
                  if (i7 <= this.l.a(i6, i4))
                  {
                    if (bool) {
                      continue;
                    }
                    if (this.l.a(i6, i4) != 2147483647) {
                      break label445;
                    }
                  }
                  if (bool) {}
                }
                else if (this.l.a(i6, i4) == 2147483647)
                {
                  this.f.a(this.o[i6].b(), locale2);
                }
                this.l.a(i6, i4, i7);
              }
              i6++;
            } while (i8 == 0);
            localm.f();
          } while (bool);
        } while (i8 == 0);
        ((w)localObject2).f();
      } while (bool);
    } while (i8 == 0);
  }
  
  public void j()
  {
    boolean bool = d.o;
    int i7 = d.n;
    a.i.n.a(this, 3, "-----> Transitive Reduction:");
    int[] arrayOfInt = new int[this.f.j()];
    a.a.x.a(this.f, arrayOfInt);
    a.i.n.a(this, 4, "Number edges:");
    a.c.n localn = this.f.C();
    m localm = this.f.w();
    a.c.d locald;
    do
    {
      if (!localm.e()) {
        break;
      }
      locald = localm.a();
      int i1 = arrayOfInt[locald.f().f()];
      localn.a(locald, i1);
      localm.f();
      if ((!bool) && (i7 != 0)) {
        break label136;
      }
    } while (i7 == 0);
    if (!bool) {
      a.i.n.a(this, 4, "Sort edges around nodes:");
    }
    label136:
    Comparator local0 = new Comparator()
    {
      private final a.c.n val$topEdge;
      
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        a.c.d locald1 = (a.c.d)paramAnonymousObject1;
        a.c.d locald2 = (a.c.d)paramAnonymousObject2;
        return a.i.l.a(this.val$topEdge.getInt(locald1), this.val$topEdge.getInt(locald2));
      }
    };
    w localw = this.f.v();
    do
    {
      if (!localw.e()) {
        break;
      }
      e locale1 = localw.d();
      a.i.n.a(this, 5, "Sort: " + b(locale1));
      if ((!bool) && (i7 != 0)) {
        break label253;
      }
      if (!bool)
      {
        if (locale1.e() > 0) {
          locale1.b(local0);
        }
        localw.f();
      }
    } while (i7 == 0);
    if (!bool) {
      this.f.a(localn);
    }
    label253:
    a locala = new a(this.m);
    localw = a.a.x.a(this.f).l();
    localw.i();
    label396:
    label553:
    do
    {
      if (!localw.e()) {
        break;
      }
      e locale2 = localw.d();
      a.i.n.a(this, 4, "Examing node: " + b(locale2));
      int i2 = b(locale2).c();
      int i3 = 0;
      if (i3 < this.m) {}
      while (bool)
      {
        locala.a(i2, i3, 2147483647);
        i3++;
        if ((!bool) && (i7 != 0)) {
          break label396;
        }
        if (i7 == 0) {
          break;
        }
      }
      locala.a(i2, i2, 0);
      localm = locale2.n();
      do
      {
        do
        {
          do
          {
            if (!localm.e()) {
              break label675;
            }
            locald = localm.a();
            i3 = b(locald.f()).c();
            int i4 = this.l.a(i2, i3);
            a.i.n.a(this, 4, "Examing edge: " + b(locald.f()) + " W: " + i4);
            if (i7 != 0) {
              break;
            }
            if (locala.a(i2, i3) != 2147483647)
            {
              if (bool) {
                break label553;
              }
              if (locala.a(i2, i3) >= i4)
              {
                this.f.a(locald);
                a.i.n.a(this, 4, "Remove Edge ! ");
                if (bool) {
                  break label672;
                }
                if (i7 == 0) {
                  break label659;
                }
              }
            }
            int i5 = 0;
            do
            {
              if (i5 >= this.m) {
                break label659;
              }
              if (i7 != 0) {
                break;
              }
              if (locala.a(i3, i5) != 2147483647)
              {
                int i6 = this.l.a(i3, i5) + i4;
                if (!bool) {
                  if (locala.a(i2, i5) != 2147483647)
                  {
                    if (bool) {
                      continue;
                    }
                    if (locala.a(i2, i5) >= i6) {
                      break label651;
                    }
                  }
                }
                locala.a(i2, i5, i6);
              }
              i5++;
            } while (i7 == 0);
            localm.f();
          } while (bool);
        } while (i7 == 0);
        localw.g();
      } while (bool);
    } while (i7 == 0);
    label651:
    label659:
    label672:
    label675:
    return;
  }
  
  private void d(int paramInt, f paramf)
  {
    boolean bool = d.o;
    int i1 = d.n;
    a.i.n.a(this, 5, "Init max-dist graph: ");
    this.j = this.f.B();
    a.f.h.b.k localk1;
    a.f.h.b.k localk2;
    if (!bool)
    {
      switch (paramInt)
      {
      case 0: 
        localk1 = a.f.h.b.k.b;
        localk2 = a.f.h.b.k.d;
        if (!bool) {
          if (i1 == 0) {
            break label123;
          }
        }
      case 1: 
        localk1 = a.f.h.b.k.c;
        localk2 = a.f.h.b.k.a;
        if (bool) {
          break label122;
        }
        if (i1 == 0) {
          break label123;
        }
      }
      a.i.n.a(this, 5, "Constraint Graph Constructor: Unknown type:" + paramInt);
    }
    label122:
    return;
    label123:
    y localy = paramf.l();
    do
    {
      if (!localy.e()) {
        break;
      }
      j localj = (j)localy.j();
      if (localj.d() != 1)
      {
        d locald1 = null;
        d locald2 = null;
        if (localj.e().c(localk1))
        {
          locald1 = a(localj.a());
          locald2 = a(localj.b());
        }
        if (localj.e().c(localk2))
        {
          locald1 = a(localj.b());
          locald2 = a(localj.a());
        }
        if ((bool) || ((locald1 != null) && (locald2 != null)))
        {
          k localk = new k(locald1, locald2, localj.c());
          this.j.a(locald1.b(), localk);
          this.j.a(locald2.b(), localk);
        }
      }
      localy.f();
    } while (i1 == 0);
  }
  
  String k()
  {
    boolean bool = d.o;
    int i1 = d.n;
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append("Segments of type: " + this.d + "\n");
    do
    {
      y localy = this.n.h();
      while (i1 == 0)
      {
        if (!localy.e()) {
          break;
        }
        if (i1 != 0) {
          break label118;
        }
        localStringBuffer.append(localy.j().toString() + "\n");
        localy.f();
      }
    } while (bool);
    label118:
    return localStringBuffer.toString();
  }
  
  String l()
  {
    boolean bool = d.o;
    int i1 = d.n;
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append("Min Dist relations: " + this.d + "\n");
    m localm = this.f.w();
    do
    {
      if (!localm.e()) {
        break;
      }
      a.c.d locald = localm.a();
      d locald1 = b(locald.e());
      d locald2 = b(locald.f());
      if (!bool)
      {
        if (i1 != 0) {
          break label159;
        }
        localStringBuffer.append(locald.toString() + " " + a(locald1, locald2) + "\n");
        localm.f();
      }
    } while (i1 == 0);
    label159:
    return localStringBuffer.toString();
  }
  
  private a.c.d a(e parame, a.f.h.b.k paramk, f paramf)
  {
    boolean bool = d.o;
    int i1 = d.n;
    m localm = parame.n();
    do
    {
      if (!localm.e()) {
        break;
      }
      a.c.d locald = localm.a();
      if (!bool)
      {
        if (paramf.i(locald).c(paramk)) {
          return locald;
        }
        localm.f();
      }
    } while (i1 == 0);
    return null;
  }
  
  public q m()
  {
    return this.f;
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.h.c.l

 * JD-Core Version:    0.7.0.1

 */